package lanQiaoBei.基础算法.高精度;

import java.util.*;
import java.io.*;

/*
 * "高精度除法" A/b 商C 余r
 * */
public class P3 {
    static ArrayList<Integer> A = new ArrayList();
    static int b;
    static ArrayList<Integer> C = new ArrayList();
    static int r;

    public static void main(String[] args) throws Exception {
        scan();
        div(A, b);
        while (!C.isEmpty())
            System.out.print(C.remove(C.size() - 1));
        System.out.println();
        System.out.print(r);
    }

    private static void div(ArrayList<Integer> a, int b) {
        r = 0;
        for (int i = a.size() - 1; i >= 0; i--) {
            r = r * 10 + a.get(i);
            C.add(r / b);
            r %= b;
        }
        Collections.reverse(C);
        //去除前导0
        while (C.size() > 1 && C.get(C.size() - 1) == 0)
            C.remove(C.size() - 1);

    }

    public static void scan() throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String s = br.readLine();
        for (int i = s.length() - 1; i >= 0; i--) {
            A.add(s.charAt(i) - '0');
        }
        s = br.readLine();
        b = Integer.parseInt(s);
    }
}
